﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LongQuanWeb.App_Code;

namespace LongQuanWeb.Admin
{
    public partial class Home_Introduction : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((this.Session["username"] == null) || (this.Session["username"].ToString() == string.Empty))
            {
                base.Response.Write("<font color=#ff0000 style='FONT-SIZE: 12px'>对不起,您没足够权限访问此页!!</font><br>");
                base.Response.Write("<a href='Login.aspx' target=_top style='FONT-SIZE: 12px'>重新登陆</a><br>");
                base.Response.End();
            }
            if (!IsPostBack)
            {
                base.Response.Write("<script>parent.window.document.getElementById( 'lbl_title').innerHTML='家园简介'; </script>");
                string strSql = "select Introduction from [VentureInfo] Where ID=4";
                DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
                if (dt != null)
                {
                    this.txtContent2.Value = dt.Rows[0]["Introduction"].ToString().Trim();
                }
            }
        }

        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string sql = "Update [VentureInfo] set Introduction='" + this.txtContent2.Value.Trim() + "' where ID=4";
                if (DbHelperSQL.ExecuteSql(sql) > 0)
                {
                    base.Response.Write("<script>alert('修改成功');window.location='Home_Introduction.aspx'</script>");
                }
                else
                {
                    base.Response.Write("<script>alert('修改失败');</script>");
                }
            }

            catch (Exception er)
            {
                Response.Write(" <script defer>alert('" + er.Message + "') </script>");
            }
        }
    }
}
